/********************************************************************
	created:	2010/01/31
	created:	31:1:2010   20:45
	filename: 	qySphere.h
	author:		Xiong Jiayu
	copyright:  
	purpose:	
*********************************************************************/
#pragma once

#ifndef __QYSPHERE_H__
#define __QYSPHERE_H__

#include "qyMath.h"
#include "qyVector3.h"

/*
===========================================
struct Sphere
===========================================
*/
struct Sphere
{
	float			radius;
	Vector3			origin;
	
					Sphere();
					Sphere( const Sphere &rhs );
					Sphere( const Vector3 &pos, const float radius );
					Sphere( const Vector3 &pos );
	
	float			operator[]( const int index ) const;
	float &			operator[]( const int index );
	Sphere			operator+( const Vector3 &v ) const;
	Sphere &		operator+=( const Vector3 &v );

	bool			Compare( const Sphere &a ) const;
	bool			Compare( const Sphere &a, const float epsilon ) const;
	bool			operator==( const Sphere &a ) const;
	bool			operator!=( const Sphere &a ) const;

	void			Zero( void );
	void			SetOrigin( const Vector3 &v );
	void			SetRadius( const float r );
	const Vector3	GetOrigin( void ) const; 
	float			GetRadius( void ) const;

	bool			AddPoint( const Vector3 &p );
	bool			AddSphere( const Sphere &s );
	Sphere			Expand( const float d ) const;
	Sphere &		ExpandSelf( const float d );
	Sphere			Translate( const Vector3 &trans ) const;
	Sphere &		TranslateSelf( const Vector3 &trans );

	float			PlaneDistance( const Plane &plane ) const;
	int				PlaneSide( const Plane &plane, const float epsilon ) const;

	bool			ContainsPoint( const Vector3 &p ) const;
	bool			InterectSphere( const Sphere &s ) const;
	bool			InterectAABB( const AABB &aabb ) const;

};

#endif
